var spider_host = "http://www.spider.com.cn";
//登陆（登录成功后页面跳转方式）
function checkLoginForm(){
	var username = $("#username").val();
	var password = $("#password").val();
	var reshcode = $("#reshcode").val();
	var remb = "n";
	if($('#remb').is(':checked')){
    	remb = "y";
	}
	if(username == "" || username == "用户名/手机号码/邮箱"){
		$("#usererrorinfo").html("请输入你注册的邮箱/手机");
		$("#username").focus();
		return false;
	}else{
		$("#usererrorinfo").html("");
	}
	if(password == ""){
		$("#pwderrorinfo").html("请输入密码");
		$("#password").focus();
		return false;
	}else{
		$("#pwderrorinfo").html("");
	}
	if(reshcode == ""){
		$("#codeerrorinfo").html("请输入验证码");
		$("#reshcode").focus();
		return false;
	}else{
		$("#codeerrorinfo").html("");
	}
	$("#clickloginbutton").html("<a id=\"loginbutton\" href=\"javascript:void(0)\" class=\"btn_red2 f14 mr20\">登　录</a>");
	var url_remote = "login.action";
	var data = {
		"logintype":"loginVer",
		"useremail":username,
		"password":password,
		"randomid":reshcode,
		"tkd":$("#tkd").val(),
		"remb":remb
	};
	$.post(url_remote, data, function(data){
    	var items = data.getElementsByTagName("item");
  		var result = items[0].childNodes[0].nodeValue;
   		if(result != "success"){
   			$("#clickloginbutton").html("<a id=\"loginbutton\" href=\"javascript:void(0)\" onclick=\"checkLoginForm()\" class=\"btn_red2 f14 mr20\">登　录</a>");
   			if(result == 'error1'){
   				$("#codeerrorinfo").html("您输入的验证码错误");
				$("#reshcode").focus();
   			}else if(result == 'error2'){
   				$("#usererrorinfo").html("请输入你注册的邮箱/手机");
				$("#username").focus();
   			}else if(result == 'error3'){
   				$("#pwderrorinfo").html("请输入密码");
				$("#password").focus();
   			}else if(result == 'F1003'){
   				$("#usererrorinfo").html("账号异常,请联系蜘蛛网客服");
				$("#username").focus();
   			}else if(result == 'F1006'){
   				$("#usererrorinfo").html("该帐号已失效");
				$("#username").focus();
   			}else if(result == 'F1007' || result == 'F1008' || result == "F1022"){
   				$("#pwderrorinfo").html("您输入的用户名或密码错误");
				$("#password").focus();
   			}else if(result == 'error8' || result == 'F1001' || result == 'F1002' || result == "F1005"){
   				$("#codeerrorinfo").html("系统繁忙,请稍后再试");
				$("#reshcode").focus();
   			}else if(result == 'error9'){
   				$("#codeerrorinfo").html("请刷新页面重新登录");
				$("#reshcode").focus();
   			}else{
   				$("#codeerrorinfo").html("访问太频繁，休息一会吧");
				$("#reshcode").focus();
   			}
       		randomidbetter(document.loginform.verifycode_id);
     		return false;
     	}
     	var posturl = "userlogin.html?returnurl="+encodeURIComponent(location.href);
       	document.loginform.action = posturl;
		document.loginform.submit();
	});
}

//登陆（登录成功后页面不跳转方式，同时可执行其他方法）
function checkLoginFormNew(pageFrom,pageAction){
	var username = $("#username").val();
	var password = $("#password").val();
	var reshcode = $("#reshcode").val();
	var remb = "n";
	if($('#remb').is(':checked')){
    	remb = "y";
	}
	if(username == "" || username == "用户名/手机号码/邮箱"){
		$("#usererrorinfo").html("请输入你注册的邮箱/手机");
		$("#username").focus();
		return false;
	}else{
		$("#usererrorinfo").html("");
	}
	if(password == ""){
		$("#pwderrorinfo").html("请输入密码");
		$("#password").focus();
		return false;
	}else{
		$("#pwderrorinfo").html("");
	}
	if(reshcode == ""){
		$("#codeerrorinfo").html("请输入验证码");
		$("#reshcode").focus();
		return false;
	}else{
		$("#codeerrorinfo").html("");
	}
	$("#clickloginbutton").html("<a id=\"loginbutton\" href=\"javascript:void(0)\" class=\"btn_red2 f14 mr20\">登　录</a>");
	var url_remote = "login.action";
	var data = {
		"logintype":"loginVer",
		"useremail":username,
		"password":password,
		"randomid":reshcode,
		"tkd":$("#tkd").val(),
		"remb":remb
	};
	$.post(url_remote, data, function(data){
    	var items = data.getElementsByTagName("item");
  		var result = items[0].childNodes[0].nodeValue;
   		if(result != "success"){
   			$("#clickloginbutton").html("<a id=\"loginbutton\" href=\"javascript:void(0)\" onclick=\"checkLoginForm()\" class=\"btn_red2 f14 mr20\">登　录</a>");
   			if(result == 'error1'){
   				$("#codeerrorinfo").html("您输入的验证码错误");
				$("#reshcode").focus();
   			}else if(result == 'error2'){
   				$("#usererrorinfo").html("请输入你注册的邮箱/手机");
				$("#username").focus();
   			}else if(result == 'error3'){
   				$("#pwderrorinfo").html("请输入密码");
				$("#password").focus();
   			}else if(result == 'F1003'){
   				$("#usererrorinfo").html("账号异常,请联系蜘蛛网客服");
				$("#username").focus();
   			}else if(result == 'F1006'){
   				$("#usererrorinfo").html("该帐号已失效");
				$("#username").focus();
   			}else if(result == 'F1007' || result == 'F1008' || result == "F1022"){
   				$("#pwderrorinfo").html("您输入的用户名或密码错误");
				$("#password").focus();
   			}else if(result == 'error8' || result == 'F1001' || result == 'F1002' || result == "F1005"){
   				$("#codeerrorinfo").html("系统繁忙,请稍后再试");
				$("#reshcode").focus();
   			}else if(result == 'error9'){
   				$("#codeerrorinfo").html("请刷新页面重新登录");
				$("#reshcode").focus();
   			}else{
   				$("#codeerrorinfo").html("访问太频繁，休息一会吧");
				$("#reshcode").focus();
   			}
       		randomidbetter(document.loginform.verifycode_id);
     		return false;
     	}else{
     		/**加载用户信息**/
   			loadUserInfo();
     		//$('.mask').hide();
     		$('#signinPop').hide();
	     	/**购物车页面或者通用的弹窗登录之后刷新一下**/
	     	if("ordercart" == pageFrom || "commonfresh" == pageFrom){
	     		var posturl = "/userlogin.html?returnurl="+encodeURIComponent(location.href);
		       	document.loginform.action = posturl;
				document.loginform.submit();
	     	/**报刊、图书详情页面**/
	     	}else if("productdetail" == pageFrom){
	     		/**判断是否独立成单、建行一元、加入购物车**/
	     		var addtype = $("#addtype").val();
	     		if("ccbqiang" == addtype){
	     			ordercart('ccbqiang');
	     		}else if("independorder" == addtype){
	     			ordercart('independorder');
	     		}else{
	     			ordercart('addcart');
	     		}
	     	/**演出票详情页面**/
	     	}else if("productdetailforpq" == pageFrom){
	     		/**是否独立成单**/
     			var isindependorderfalg = $("#isindependorderfalg").val();
     			if("true" == isindependorderfalg){
     				cnbank_szh_act('independorder','pq');
     			}else{
     				ordercart('one', 'pq');
     			}
	     	/**礼品详情页面**/
	     	}else if("productdetailforlp" == pageFrom){
	     		$("#addtrly").click();
	     	}
     	}
	});
}

/**获取url参数值**/
function getUrlParam(name){
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	var r = window.location.search.substr(1).match(reg);  //匹配目标参数
	//返回参数值
	if(r != null){
		return unescape(r[2]);
	}else{
		return "";
	}
}

function showrgsttips(id){
	if(id == 'pwd_tip'){
		$("#"+id).html("6~16个字符（字母，数字），区分大小写");
	}else if(id == 'repwd_tip'){
		$("#"+id).html("请再输一遍您要设置的密码");
	}else if(id == 'mobile_tip'){
		$("#"+id).html("找回密码和接收电子优惠券用<div class=\"red1\">成功绑定手机，可获赠100积分</div>");
	}
	$("#"+id).show();
	
}
var rightimg = "<span style=\"margin-top:4px; margin-right:5px; \"><img src='../images/zc1_03.jpg'></span>";
var errorimg = "<span style=\"margin-top:4px; margin-right:5px; \"><img src='../images/cw_03.jpg'></span>";
function checkemail(value,tipid){
	if(null == value || '' == value){
		$("#"+tipid).html(errorimg + " 请输入的电子邮箱");
	}else if(!is_email(value)){
		$("#"+tipid).html(errorimg + " 您输入的电子邮箱地址格式不正确");
	}else{
		$("#"+tipid).html(rightimg);
	}
}
var pwdreg = /^(\w|,){6,16}/;
function checkpwd(value,tipid){
	if(null == value || '' == value){
		$("#"+tipid).html(errorimg + " 请输入密码");
	}else if(!pwdreg.test(value)){
		$("#"+tipid).html(errorimg + " 密码必须是6-16位字符，请正确输入");//密码长度最少要大于6位
	}else{
		$("#"+tipid).html(rightimg);
	}
}

function checkrepwd(value,tipid){
	var pwd =  $("#pwd").val();
	if(null == value || '' == value){
		$("#"+tipid).html(errorimg + " 请输入确认密码");
	}else if(!pwdreg.test(value)){
		$("#"+tipid).html(errorimg + " 密码必须是6-30位字符，请正确输入");//密码长度最少要大于6位
	}else if(pwd != value){
		$("#"+tipid).html(errorimg + " 您两次输入的密码不一致，请重新输入");
	}else{
		$("#"+tipid).html(rightimg);
	}
}

function checkmobile(value,tipid){
	if(null != value && '' != value){
		if(!cellphone.test(value)){
			$("#"+tipid).html(errorimg + " 手机号码不正确");
		}else{
			$("#"+tipid).html(rightimg);
		} 
	}
}

var cellphone=/^1\d{10}$/;
var temptime = 100;
function getverifycode(tipid){
	temptime = 100;
	var mobile = $("#mobile").val();
	$("#"+tipid).show();
	if(null == mobile || '' == mobile){
		$("#"+tipid).html(errorimg + " 手机号码不正确");
	}else if(!cellphone.test(mobile)){
		$("#"+tipid).html(errorimg + " 您输入的不正确");
	}else{
	    var sdbuttonObj = document.getElementById("mcodebtn"); 
	    sdbuttonObj.disabled = "disabled";
	    var url_remote = "userJquery.action?commonType=user0001";
	    url_remote = encodeURI(url_remote);
	    var key = "";
	    $.post(url_remote, null, 
	    function(data) {
	        var items0 = data.getElementsByTagName("item");
	        key = items0[0].childNodes[0].nodeValue;
	        
	        url_remote = "userJquery.action?commonType=user001&mobile=" + mobile+"&key="+key;
		    url_remote = encodeURI(url_remote);
		    $.post(url_remote, null, 
		    function(data) {
		        var items = data.getElementsByTagName("item");
		        var times = items[0].childNodes[0].nodeValue;
		        if (times == 'success') {
		            if (null != sdbuttonObj) {
		                sdbuttonObj.value = "获取验证码(" + temptime + ")";
		                document.getElementById("btNum").value = "0";
		                $("#mobile_tip").html("验证码已发送，请注意查收。因运营商短信业务调整，部分会员无法接受短信。请直接注册");
		            }
		        } else {
		            document.getElementById("btNum").value = "1";
		            sdbuttonObj.disabled = "enabled";
		        }
		    });
		    
	    });
	}
}

function bt_getvalue() {
    var url_remote = "userJquery.action?commonType=user007";
    url_remote = encodeURI(url_remote);
    $.post(url_remote, null, 
    function(data) {
        var items = data.getElementsByTagName("item");
        var valjq = items[0].childNodes[0].nodeValue;
        if (valjq == 'false') {
        	ettemptime(0);
        } else {
            settemptime(valjq);
            document.getElementById("btNum").value = "0";
            document.getElementById("mcodebtn").value = "获取验证码(" + valjq + ")";
            document.getElementById("mcodebtn").disabled = "disabled";
        }
    });
}

function settemptime(value){
	temptime = value;
}

function bt(){
    var sdbuttonObj = document.getElementById("mcodebtn");
   	var btNum = document.getElementById("btNum").value;
    if (null != sdbuttonObj && "0" == btNum) {
        if (temptime > 0) {
            sdbuttonObj.disabled = "disabled";
            sdbuttonObj.value = "获取验证码(" + temptime + ")"
        } else {
            sdbuttonObj.disabled = "";
            sdbuttonObj.value = "获取手机验证码";
            return false
        }
        temptime--
    }
}

function checkmcode(value,tipid){
	if(null != value && '' != value){
		if(value.length <6){
			$("#"+tipid).html(errorimg + " 验证码为6位数字");
		}else{
			$("#"+tipid).html(rightimg);
		}
	}
}

function checkRegisterForm(){
	var email = $("#email").val();
	var pwd	  = $("#pwd").val();
	var repwd = $("#repwd").val();
	var mobile= $("#mobile").val();
	var mcode = $("#mobile_code").val();
	var pccode= $("#verifycode").val();
	if(null == email || '' == email){
		$("#email").focus();
		$("#email_tip").show();
		$("#email_tip").html(errorimg + " 请输入的电子邮箱");
		return; 
	}else if(!is_email(email)){
		$("#email").focus();
		$("#email_tip").show();
		$("#email_tip").html(errorimg + " 您输入的电子邮箱格式不正确");
		return; 
	}else{
		var url_remote = "register.action?useremail=" + email + "&registertype=registertype";
        url_remote = encodeURI(url_remote);
		$.post(url_remote, null, function(data){
        	var items = data.getElementsByTagName("item");   
    		var bool = items[0].childNodes[0].nodeValue;
   			if(bool == "true"){
   				$("#email_tip").html(rightimg);
   				if(null == pwd || '' == pwd){
					$("#pwd_tip").show();
					$("#pwd_tip").html(errorimg +" 请输入密码");
					return; 
				}else if(!pwdreg.test(pwd)){
					$("#pwd").focus();
					$("#pwd_tip").show();
					$("#pwd_tip").html(errorimg + " 密码必须是6-16位字符，请正确输入");//密码长度最少要大于6位
					return; 
				}
				if(null == repwd || '' == repwd){
					$("#repwd").focus();
					$("#repwd_tip").show();
					$("#repwd_tip").html(errorimg +" 请输入确认密码");
					return; 
				}else if(!pwdreg.test(repwd)){
					$("#repwd").focus();
					$("#repwd_tip").show();
					$("#repwd_tip").html(errorimg  + " 密码必须是6-16位字符，请正确输入");//密码长度最少要大于6位
					return; 
				}else if(pwd != repwd){
					$("#repwd").focus();
					$("#repwd_tip").show();
					$("#repwd_tip").html(errorimg + " 您两次输入的密码不一致，请重新输入");
					return; 
				}
				if(null != mobile && mobile != ''){
					if(!cellphone.test(mobile)){
						$("#mobile").focus();
						$("#mobile_tip").show();
						$("#mobile_tip").html(errorimg + " 请输入正确的手机号");
						return ;
					}
					if(null != mcode && mcode != ''){
						var url_remote = "userJquery.action?commonType=user002";
					    url_remote = encodeURI(url_remote);
					    $.post(url_remote, null, function(data) {
					        var items = data.getElementsByTagName("item");
					        var jvcode = items[0].childNodes[0].nodeValue;//验证码
					        if (jvcode != mcode) {
					        	$("#mobile_code").focus();
					        	$("#mobile_code_tip").show();
					    		$("#mobile_code_tip").html(errorimg + " 您输入的手机验证码不对");
					    		return;
					        }
					        if(null == pccode || '' == pccode){
					    		$("#verifycode").focus();
					    		$("#verifycode_tip").show();
					    		$("#verifycode_tip").html(errorimg +" <span style=\"float:left;margin-top:4px;\">请输入图片验证码</span>");
					    		return; 
					    	}
					        var url_remote = "userJquery.action?commonType=user003&pjcode="+pccode;
				    	    url_remote = encodeURI(url_remote);
				    	    $.post(url_remote, null, function(data) {
				    	        var items = data.getElementsByTagName("item");
				    	        var result = items[0].childNodes[0].nodeValue;//验证码
				    	        if (result == "false") {
				    	        	$("#verifycode").focus();
				    	        	$("#verifycode_tip").show();
				    	    		$("#verifycode_tip").html(errorimg + " <span style=\"float:left;margin-top:4px;\"> 您输入的图片验证码不对</span>");
				    	    		return;
				    	        }
				    	        var agreement = $("#agreement").attr("checked");
						    	if(!agreement){
						    		alert("很抱歉，您必须同意蜘蛛网用户注册协议后才能注册");
						    		return;
						    	}
						    	$("#checkbutton").attr("disabled", true);
						    	document.registerform.action =  "userregister.html";
						    	document.registerform.submit();
				    	    })
					    })
					}else{
						if(null == pccode || '' == pccode){
				    		$("#verifycode").focus();
				    		$("#verifycode_tip").show();
				    		$("#verifycode_tip").html(errorimg +" <span style=\"float:left;margin-top:4px;\">请输入图片验证码</span>");
				    		return; 
				    	}
			    		var url_remote = "userJquery.action?commonType=user003&pjcode="+pccode;
			    	    url_remote = encodeURI(url_remote);
			    	    $.post(url_remote, null, function(data) {
			    	        var items = data.getElementsByTagName("item");
			    	        var result = items[0].childNodes[0].nodeValue;//验证码
			    	        if (result == "false") {
			    	        	$("#verifycode").focus();
			    	        	$("#verifycode_tip").show();
			    	    		$("#verifycode_tip").html(errorimg + " <span style=\"float:left;margin-top:4px;\"> 您输入的图片验证码不对</span>");
			    	    		return;
			    	        }
			    	        var agreement = $("#agreement").attr("checked");
					    	if(!agreement){
					    		alert("很抱歉，您必须同意蜘蛛网用户注册协议后才能注册");
					    		return;
					    	}
					    	$("#checkbutton").attr("disabled", true);
					    	document.registerform.action =  "userregister.html";
					    	document.registerform.submit();
			    	    })
					}
				}else{
					if(null == pccode || '' == pccode){
			    		$("#verifycode").focus();
			    		$("#verifycode_tip").show();
			    		$("#verifycode_tip").html(errorimg +" <span style=\"float:left;margin-top:4px;\">请输入图片验证码</span>");
			    		return; 
			    	}
			        var url_remote = "userJquery.action?commonType=user003&pjcode="+pccode;
				    url_remote = encodeURI(url_remote);
				    $.post(url_remote, null, function(data) {
				        var items = data.getElementsByTagName("item");
				        var result = items[0].childNodes[0].nodeValue;//验证码
				        if (result == "false") {
				        	$("#verifycode").focus();
				        	$("#verifycode_tip").show();
				    		$("#verifycode_tip").html(errorimg + " <span style=\"float:left;margin-top:4px;\"> 您输入的图片验证码不对</span>");
				    		return;
				        }
				        var agreement = $("#agreement").attr("checked");
				    	if(!agreement){
				    		alert("很抱歉，您必须同意蜘蛛网用户注册协议后才能注册");
				    		return;
				    	}
				    	$("#checkbutton").attr("disabled", true);
				    	document.registerform.action =  "userregister.html";
				    	document.registerform.submit();
				    })
				}
   			}else{
   				$("#email_tip").html(errorimg + " 该用户名已经被注册");
   				return ;
   			}
    	})
	}
	
	
}

function checkRegisterForm2(){
	var email = $("#email").val();
	var pwd	  = $("#pwd").val();
	var repwd = $("#repwd").val();
	var mobile= $("#mobile").val();
	var mcode = $("#mobile_code").val();
	var pccode= $("#verifycode").val();
	if(null == email || '' == email){
		$("#email").focus();
		$("#email_tip").show();
		$("#email_tip").html(errorimg + " 请输入的电子邮箱");
		return; 
	}else if(!is_email(email)){
		$("#email").focus();
		$("#email_tip").show();
		$("#email_tip").html(errorimg + " 您输入的电子邮箱格式不正确");
		return; 
	}else{
		var url_remote = "register.action?useremail=" + email + "&registertype=registertype";
        url_remote = encodeURI(url_remote);
		$.post(url_remote, null, function(data){
        	var items = data.getElementsByTagName("item");   
    		var bool = items[0].childNodes[0].nodeValue;
   			if(bool == "true"){
   				$("#email_tip").html(rightimg);
   				if(null == pwd || '' == pwd){
					$("#pwd_tip").show();
					$("#pwd_tip").html(errorimg +" 请输入密码");
					return; 
				}else if(!pwdreg.test(pwd)){
					$("#pwd").focus();
					$("#pwd_tip").show();
					$("#pwd_tip").html(errorimg + " 密码必须是6-16位字符，请正确输入");//密码长度最少要大于6位
					return; 
				}
				if(null == repwd || '' == repwd){
					$("#repwd").focus();
					$("#repwd_tip").show();
					$("#repwd_tip").html(errorimg +" 请输入确认密码");
					return; 
				}else if(!pwdreg.test(repwd)){
					$("#repwd").focus();
					$("#repwd_tip").show();
					$("#repwd_tip").html(errorimg  + " 密码必须是6-16位字符，请正确输入");//密码长度最少要大于6位
					return; 
				}else if(pwd != repwd){
					$("#repwd").focus();
					$("#repwd_tip").show();
					$("#repwd_tip").html(errorimg + " 您两次输入的密码不一致，请重新输入");
					return; 
				}
				
				if(null != mobile && mobile != '' &&!cellphone.test(mobile)){
						$("#mobile").focus();
						$("#mobile_tip").show();
						$("#mobile_tip").html(errorimg + " 请输入正确的手机号");
						return ;
				}
				if(null == pccode || '' == pccode){
				    		$("#verifycode").focus();
				    		$("#verifycode_tip").show();
				    		$("#verifycode_tip").html(errorimg +" <span style=\"float:left;margin-top:4px;\">请输入图片验证码</span>");
				    		return; 
				}
			   var url_remote = "userJquery.action?commonType=user003&pjcode="+pccode;
			   url_remote = encodeURI(url_remote);
			   $.post(url_remote, null, function(data) {
			   var items = data.getElementsByTagName("item");
			   var result = items[0].childNodes[0].nodeValue;//验证码
				
			   if (result == "false") {
				        	$("#verifycode").focus();
				        	$("#verifycode_tip").show();
				    		$("#verifycode_tip").html(errorimg + " <span style=\"float:left;margin-top:4px;\"> 您输入的图片验证码不对</span>");
				    		return;
				}
				var agreement = $("#agreement").attr("checked");
				if(!agreement){
				    		alert("很抱歉，您必须同意蜘蛛网用户注册协议后才能注册");
				    		return;
				 }
				$("#checkbutton").attr("disabled", true);
				document.registerform.action =  window.location.href;//"userregister.html";
				document.registerform.submit();
				});
   			}else{
   				$("#email_tip").html(errorimg + " 该用户名已经被注册");
   				return ;
   			}
    	});
	}
}

/** 注册或登录页面对是否为有效邮箱的验证 */
function is_email(value){
  	if( value == null || value.length == 0 )return false ;
  	var re = new RegExp("[^0-9a-z.@_\\-]","ig");
  	if( value.indexOf("@china-sorsa") >= 0 ) return true;
  	if( re.test(value) == true ) return false ;
  	re = new RegExp("@","g");
  	var ret = value.match(re);
  	if( ret == null || ret.length > 1 ) return false ;
  	if( value.indexOf(".") < 0 ) return false;
  	if( value.indexOf("@") == 0 ) return false;
  	if( value.indexOf("@.") >= 0 ) return false;
  	if( value.indexOf(".@") >= 0 ) return false;
  	if( value.indexOf("@") == value.length - 1 ) return false;
  	if( value.indexOf("@sian") >= 0 ) return false;
  	if( value.indexOf(".con") >= 0 ) return false;
  	if( value.indexOf("mial") >= 0 ) return false;
  	
  	return true ;
}


function CheckMobileCode(mobile){
	var mobile_code = $("#mobile_code").val();
	if(mobile_code == ''){
		$("#errorCodeSpan").html(errorimg + " 请输入手机验证码" );
   		return ;
	}
	var as = {"commonType":"user006", "mobile_code":mobile_code}
	$.post("userJquery.action", as, function(data){
       	var items = data.getElementsByTagName("item");   
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'false'){
     		$("#errorCodeSpan").html(errorimg + " 手机验证码不对，请确认无误后重新输入" );
     		return ;
     	}
     	document.fogetPasswordForm.action = "forgetPasswordStepThree.html?forgettype=mobile";
     	document.fogetPasswordForm.submit();
   	})
   	
}

/** 忘记密码 **/
function checkForgetPwd(){
	var forgettype = $("input[name='forgettype']:checked").val();
	var piccode ;
	if(forgettype == "email"){
		piccode = $("#piccodeA").val();
		var useremail = $("#useremail").val();
		if(useremail == ''){
			$("#errorPasswordSpanA").html(errorimg + " 请输入邮箱" );
			return ;
		}
		if(!is_email(useremail)){
			$("#errorPasswordSpanA").html(errorimg + " 邮箱格式输入有误" );
			return ;
		}
		if(piccode == ''){
			$("#errorCodeSpanA").html(errorimg + " 请输入验证码" );
     		return ;
		}
		var as = {"commonType":"user004", "pjcode":piccode, "useremail":useremail}
		$.post("userJquery.action", as, function(data){
	       	var items = data.getElementsByTagName("item");   
	     	var result = items[0].childNodes[0].nodeValue;
	     	if(result == 'false'){
	     		$("#errorCodeSpanA").html(errorimg + " 验证码不对" );
	     		randomidbetter(document.fogetPasswordForm.verifycode_id)
	     		return ;
	     	}
	     	if(result == 'false2'){
	     		$("#errorPasswordSpanA").html(errorimg + " 抱歉，无此用户" );
	     		randomidbetter(document.fogetPasswordForm.verifycode_id)
	     		return ;
	     	}
	     	document.fogetPasswordForm.action = "forgetPasswordStepTwo.html?forgettype="+forgettype;
	     	document.fogetPasswordForm.submit();
	   	})
	}else if(forgettype = "mobile"){
		piccode = $("#piccodeB").val();
		var mobile = $("#mobile").val();
		if(mobile == ''){
			$("#errorPasswordSpanB").html(errorimg + " 请输入手机号" );
			return ;
		}
		if(!cellphone.test(mobile)){
			$("#errorPasswordSpanB").html(errorimg + " 手机格式有误" );
			return ;
		}
		if(piccode == ''){
			$("#errorCodeSpanB").html(errorimg + " 请输入验证码" );
     		return ;
		}
		var as = {"commonType":"user005", "pjcode":piccode, "mobile":mobile}
		$.post("userJquery.action", as, function(data){
	       	var items = data.getElementsByTagName("item");   
	     	var result = items[0].childNodes[0].nodeValue;
	     	
	     	if(result == 'false'){
	     		$("#errorCodeSpanB").html(errorimg + " 验证码不对" );
	     		randomidbetter(document.fogetPasswordForm.verifycode_id_2)
	     		return ;
	     	}
	     	if(result == 'false2'){
	     		$("#errorPasswordSpanB").html(errorimg + " 抱歉，该手机没有绑定过账号" );
	     		randomidbetter(document.fogetPasswordForm.verifycode_id_2)
	     		return ;
	     	}
	     	if(result == 'success'){
	     		var useremail = items[1].childNodes[0].nodeValue;
	     		$("#useremailhidden").val(useremail);
	     	}
	     	document.fogetPasswordForm.action = "forgetPasswordStepTwo.html?forgettype="+forgettype;
	     	document.fogetPasswordForm.submit();
	   	})
	}
}

function checkFogetType(value){
	if(value == 'email'){
		$("#emailfinddiv").show();
		$("#mobilefinddiv").hide();
		
		randomidbetter(document.fogetPasswordForm.verifycode_id);
	}else if(value == 'mobile'){
		$("#mobilefinddiv").show();
		$("#emailfinddiv").hide();
		randomidbetter(document.fogetPasswordForm.verifycode_id_2);
	}
}

function subModifyPwd(){
	var password = $("#password").val();
	var repassword = $("#repassword").val();
	if(password == ''){
		$("#errorpwd").html(errorimg + "请输入密码");
		return ;
	}
	$("#errorpwd").html("");
	if(!pwdreg.test(password)){
		$("#errorpwd").html(errorimg  + " 密码必须是6-16位字符，请正确输入");//密码长度最少要大于6位
		return ;
	}
	$("#errorpwd").html("");
	if(repassword == ''){
		$("#errorrepwd").html(errorimg + "请输入确认密码");
		return ;
	}
	$("#errorrepwd").html("");
	if(!pwdreg.test(repassword)){
		$("#errorrepwd").html(errorimg  + " 密码必须是6-16位字符，请正确输入");//密码长度最少要大于6位
		return ;
	}
	$("#errorrepwd").html("");
	if(repassword != password){
		$("#errorrepwd").html(errorimg + "两次输入密码不一致，请重新输入");
		return ;
	}
	$("#errorrepwd").html("");
	var piccode = $("#piccodeA").val();
	if(piccode == ''){
		$("#errorCodeSpanA").html(errorimg + "请输入验证码");
		return;
	}
	$("#errorCodeSpanA").html("");
	var as = {"commonType":"user003", "pjcode":piccode}
	$.post("userJquery.action", as, function(data){
       	var items = data.getElementsByTagName("item");   
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == '401'){
     		$("#errorCodeSpanA").html(errorimg + " 验证码不对" );
     		randomidbetter(document.fogetPasswordForm.verifycode_id)
     		return ;
     	}
     	document.fogetPasswordForm.action = "forgetPasswordStepModify.html";
		document.fogetPasswordForm.submit();
   	})
	
}

function sendRegstEmail(){
	var url_remote = "sendRegstEmail.action";
    url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		alert("邮件发送成功，请注意查收邮件");
	})
}
function sendForgetEmail(){
    var useremail = $("#useremail").html();
	var as = {"commonType":"user008",  "useremail":useremail}
	$.post("userJquery.action", as, function(data){
		var items = data.getElementsByTagName("item");
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'false2'){
     		$("#errorPasswordSpanA").html(errorimg + " 抱歉，无此用户");
     		randomidbetter(document.fogetPasswordForm.verifycode_id)
     		return;
     	}
        alert("邮件发送成功，请注意查收邮件");
   	})
}

function randomidbetter(obj) {
	obj.src = spider_host + "/verifycode.jsp?" + new Date;
}


function closeloginform(){
	$(".mask").hide();
	$("#signinPop").hide();
	document.loginform.reset();
}

/**登录后加载用户信息**/
function loadUserInfo(){
	$.ajax({
		async:false,//使用同步的Ajax请求  
		type: "POST",  
		url: "newuserjquery.action?usertype=four004",  
		data: "",  
		success: function(data){
			var items = data.getElementsByTagName("item");
	     	var result = items[0].childNodes[0].nodeValue;
	     	var cusid = items[1].childNodes[0].nodeValue;
	     	if(result.indexOf("@") > -1){
	     		result = result.split("@")[0];
	     	}
	     	var logincontent = "<span class=\"fl mr15\">你好，<a href=\"" + spider_host + "/accountinfo.html\" target=\"_blank\">" + result + "</a></span>";
			logincontent += "<a href=\"" + spider_host + "/accountmessage.html\" class=\"message fl mr10 pl15\">消息(<em class=\"red2\">0</em>)</a>";
			logincontent += "<a href=\"" + spider_host + "/userexit.html\" class=\"fl mr15\">退出</a>";
	     	$("#changelogininfo").html(logincontent);
	     	customerid = cusid;
		}
	});
}